SET NOCOUNT ON
GO

IF OBJECT_ID('Test_') IS NOT NULL DROP PROCEDURE Test_
IF OBJECT_ID('Test_ME') IS NOT NULL DROP PROCEDURE Test_ME
IF OBJECT_ID('Test_ME_TEST') IS NOT NULL DROP PROCEDURE Test_ME_TEST
IF OBJECT_ID('Test_ME_PROD') IS NOT NULL DROP PROCEDURE Test_ME_PROD
IF OBJECT_ID('Test_DEFAULT') IS NOT NULL DROP PROCEDURE Test_DEFAULT
IF OBJECT_ID('Test_DEFAULT_TEST') IS NOT NULL DROP PROCEDURE Test_DEFAULT_TEST
GO

CREATE PROCEDURE Test_ @DelegateName varchar(50)
AS
BEGIN
	RETURN NULL
END
GO

CREATE PROCEDURE Test_ME
AS
BEGIN
	PRINT 'this is interface test_ called by @DelegateName ME '
END
GO

CREATE PROCEDURE Test_ME_TEST
AS
BEGIN
	PRINT 'this is interface test_ called by @DelegateName ME when configured for TEST'
END
GO

CREATE PROCEDURE Test_ME_PROD
AS
BEGIN
	PRINT 'this is interface test_ called by @DelegateName ME when configured for PROD'
END
GO


CREATE PROCEDURE Test_DEFAULT
AS
BEGIN
	PRINT 'this is the default delegate for interface test_ '
END
GO

CREATE PROCEDURE Test_DEFAULT_TEST
AS
BEGIN
	PRINT 'this is the default delegate for interface test_ when configured for TEST'
END
GO


PRINT '--'
PRINT 'Without config'
PRINT '--'

exec qic.Compile
exec Test_'ME'
exec Test_'YOU'

PRINT '--'
PRINT 'Config TEST'
PRINT '--'

exec qic.Compile 'TEST'
exec Test_'ME'
exec Test_'YOU'

PRINT '--'
PRINT 'Config PROD'
PRINT '--'

exec qic.Compile 'PROD'
exec Test_'ME'
exec Test_'YOU'

GO

IF OBJECT_ID('Test_') IS NOT NULL DROP PROCEDURE Test_
IF OBJECT_ID('Test_ME') IS NOT NULL DROP PROCEDURE Test_ME
IF OBJECT_ID('Test_ME_TEST') IS NOT NULL DROP PROCEDURE Test_ME_TEST
IF OBJECT_ID('Test_ME_PROD') IS NOT NULL DROP PROCEDURE Test_ME_PROD
IF OBJECT_ID('Test_DEFAULT') IS NOT NULL DROP PROCEDURE Test_DEFAULT
IF OBJECT_ID('Test_DEFAULT_TEST') IS NOT NULL DROP PROCEDURE Test_DEFAULT_TEST
GO
